from bs4 import BeautifulSoup
htmlContent = """
<html><head><title>My Title</title></head>
<body>
</body>
</html>
"""
#把解析好的对象放入soup
soup = BeautifulSoup(htmlContent, "html.parser")
#输出My Title
print(soup.title.string)
#输出<class 'bs4.element.NavigableString'>
print(type(soup.title.string))
